package com.zwp.base.binding

import android.widget.ImageView
import androidx.databinding.BindingAdapter
import coil.load
import coil.transform.Transformation

@BindingAdapter(value = ["url", "placeholder", "transformation"], requireAll = false)
fun setImageUrl(
    imageView: ImageView,
    url: String,
    placeholder: Int = 0,
    transformation: Transformation?
) {
    imageView.load(url) {
        if (placeholder != 0) {
            placeholder(placeholder)
        }
        if (transformation != null) {
            transformations(transformation)
        }
    }
}